package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import com.itheima.SysLogService;
import com.itheima.dao.SysLogDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service(interfaceClass = SysLogService.class)
@Transactional
public class SysLogServiceImp implements SysLogService {
    @Autowired
    private SysLogDao sysLogDao;

    @Override
    public void save(SysLog sysLog) {
        sysLogDao.save(sysLog);
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        Page page = PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        List<SysLog> sysLogs = sysLogDao.findByQueryString(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(), sysLogs);

    }

    @Override
    public void delete(Integer id) {
        sysLogDao.delete(id);
    }
}
